package com.waigoulin.test.infrastructure.gateway;

import com.alibaba.fastjson.JSON;
import com.waigoulin.infrastructure.gateway.IpLocationApiService;
import com.waigoulin.infrastructure.gateway.dto.lbs.IpLocationResponseDTO;
import com.waigoulin.types.sdk.lbs.IpLocationUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import retrofit2.Call;

import javax.annotation.Resource;
import javax.xml.stream.Location;
import java.io.IOException;

/**
 * @FileName IpLocationApiServiceTest
 * @Description IP地址解析地理位置api测试
 * @Author waigoulin
 * @date 2025-07-30
 **/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class IpLocationApiServiceTest {

    @Resource
    IpLocationApiService ipLocationApiService;

    @Test
    public void testIpLocationApiService() throws IOException {
        String ip = IpLocationUtil.getLoginIp();
        Call<IpLocationResponseDTO> call = ipLocationApiService.getIpLocation(ip, "true");
        IpLocationResponseDTO ipLocationResponseDTO = call.execute().body();
        assert ipLocationResponseDTO != null;
        log.info("测试结果:{}", JSON.toJSONString(ipLocationResponseDTO));
    }


}


